package com.xuyanhao.waiterservice.spring.springbucks.waiter.support;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.joda.money.Money;

import java.io.IOException;

public class MoneySerializer extends StdSerializer<Money> {
  protected MoneySerializer() {
    super(Money.class);
  }

  @Override
  public void serialize(Money value, JsonGenerator gen, SerializerProvider provider)
      throws IOException {
    gen.writeNumber(value.getAmount());
  }
}
